#include <algorithm>
#include <iostream>
using namespace std;
#include <vector>
#include <unordered_map>

class Solution
{
public:
    static vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        unordered_map<string, vector<string>> hash;
        for(auto s : strs)
        {
            string tmp = s;
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(s);
        }

        vector<vector<string>> rv;
        for(auto& [x,y] : hash)
        {
            rv.push_back(y);
        }
        return rv;
    }
};